package com.ruoyi.groupReport.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.groupReport.domain.Groupreport;
import com.ruoyi.groupReport.service.IGroupreportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信息记录Controller
 * 
 * @author yjh
 * @date 2024-08-22
 */
@RestController
@RequestMapping("/groupReport/groupReport")
public class GroupreportController extends BaseController
{
    @Autowired
    private IGroupreportService groupreportService;

    /**
     * 查询信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('groupReport:groupReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(Groupreport groupreport)
    {
        startPage();
        List<Groupreport> list = groupreportService.selectGroupreportList(groupreport);
        return getDataTable(list);
    }

    /**
     * 导出信息记录列表
     */
    @PreAuthorize("@ss.hasPermi('groupReport:groupReport:export')")
    @Log(title = "信息记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Groupreport groupreport)
    {
        List<Groupreport> list = groupreportService.selectGroupreportList(groupreport);
        ExcelUtil<Groupreport> util = new ExcelUtil<Groupreport>(Groupreport.class);
        util.exportExcel(response, list, "信息记录数据");
    }

    /**
     * 获取信息记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('groupReport:groupReport:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(groupreportService.selectGroupreportById(id));
    }

    /**
     * 新增信息记录
     */
    @PreAuthorize("@ss.hasPermi('groupReport:groupReport:add')")
    @Log(title = "信息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Groupreport groupreport)
    {
        return toAjax(groupreportService.insertGroupreport(groupreport));
    }

    /**
     * 修改信息记录
     */
    @PreAuthorize("@ss.hasPermi('groupReport:groupReport:edit')")
    @Log(title = "信息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Groupreport groupreport)
    {
        return toAjax(groupreportService.updateGroupreport(groupreport));
    }

    /**
     * 删除信息记录
     */
    @PreAuthorize("@ss.hasPermi('groupReport:groupReport:remove')")
    @Log(title = "信息记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(groupreportService.deleteGroupreportByIds(ids));
    }
}
